<?php

//require_once __DIR__ . '/../../../../../vendor/autoload.php';
//加载GatewayClient。关于GatewayClient参见本页面底部介绍
require_once __DIR__ . '/../../../../../../vendor/workerman/gatewayclient/Gateway.php';

// GatewayClient 3.0.0版本开始要使用命名空间
use GatewayClient\Gateway;
// 设置GatewayWorker服务的Register服务ip和端口，请根据实际情况改成实际值
Gateway::$registerAddress = '127.0.0.1:2346';

if('1'==$_GET['report']){
    error_reporting (0);
    register_shutdown_function($err = 'my_error_handler_TEST') OR set_error_handler($err,E_ALL); // 同时注册两个函数.
}

$uid=$_GET['uid'];
$message=$_GET['msg'];

echo "<br/>$uid # $message </br>";

// 向任意uid的网站页面发送数据
Gateway::sendToUid($uid, json_encode(array('type'=>'msg','content'=>$message,)) );


function my_error_handler_TEST($errno=0 ,$errstr=0 , $errfile=0 ,$errline=0){
    if($errno && $errfile){
        if(true){
            $earr = array();
            $earr['type'] = $errno;
            $earr['message'] = $errstr;
            $earr['file'] = $errfile;
            $earr['line'] = $errline;
        }
    }else{
        $earr = error_get_last();
    }
    if(null != $earr){
    echo '<pre>';
    print_r($earr);
    echo '</pre>';
    }
}